﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace PressMenu2
{
    class DiaBay : GameObject
    {
        int vx = 0;
        int vy = 0;

        public DiaBay(int id, int player) : base(id, player)
        {
            texture = MyResource.tDiaBay[id];

            float y = 0, x = 1100;
            //x = Helper.Random(0, 1000); 
            y = Helper.Random(0,400);
            Position = new Vector2(x, y);
            rectangle = new Rectangle((int)x, (int)y, texture.Width, texture.Height);
            vy = Helper.Random(1, 3);
            vx = Helper.Random(1, 4);
        }

        public override int Update(GameTime gameTime, MyInput input)
        {
            float x=position.X, y=position.Y;
            x  -= vx;
            if (x < -texture.Width)
            {
                x = cDef.WindowWidth + texture.Width;
                y = Helper.Random(0, 400);
                Position = new Vector2(x, y);
                return 2;
            }
            
            vy = Helper.Random(-2, 2);
            y -= vy;

            Position = new Vector2(x, y);
            if (Blood <= 0)
                return -1;
            return 0;
        }

    }
}
